From 221db8e02516702b14e12e19f3256b2d49a4f256 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 5 Oct 2004 05:40:42 +0000 Subject: [PATCH] Return a new reference to an existing GdkWindow if one already exists. 2004-10-05 Matthias Clasen * gdk/x11/gdkwindow-x11.c (gdk_window_foreign_new_for_display): Return a new reference to an existing GdkWindow if one already exists. (#151378, Gustavo Carneiro) --- ChangeLog | 6 ++++++ ChangeLog.pre-2-10 | 6 ++++++ ChangeLog.pre-2-6 | 6 ++++++ ChangeLog.pre-2-8 | 6 ++++++ gdk/x11/gdkwindow-x11.c | 14 ++++++++++---- 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 459fbc2ac9..1dfdc901b3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-10-05 Matthias Clasen + + * gdk/x11/gdkwindow-x11.c (gdk_window_foreign_new_for_display): + Return a new reference to an existing GdkWindow if one already + exists. (#151378, Gustavo Carneiro) + 2004-10-05 Matthias Clasen Provide access to the string representation of accelerators used diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 459fbc2ac9..1dfdc901b3 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,9 @@ +2004-10-05 Matthias Clasen + + * gdk/x11/gdkwindow-x11.c (gdk_window_foreign_new_for_display): + Return a new reference to an existing GdkWindow if one already + exists. (#151378, Gustavo Carneiro) + 2004-10-05 Matthias Clasen Provide access to the string representation of accelerators used diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 459fbc2ac9..1dfdc901b3 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,9 @@ +2004-10-05 Matthias Clasen + + * gdk/x11/gdkwindow-x11.c (gdk_window_foreign_new_for_display): + Return a new reference to an existing GdkWindow if one already + exists. (#151378, Gustavo Carneiro) + 2004-10-05 Matthias Clasen Provide access to the string representation of accelerators used diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 459fbc2ac9..1dfdc901b3 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,9 @@ +2004-10-05 Matthias Clasen + + * gdk/x11/gdkwindow-x11.c (gdk_window_foreign_new_for_display): + Return a new reference to an existing GdkWindow if one already + exists. (#151378, Gustavo Carneiro) + 2004-10-05 Matthias Clasen Provide access to the string representation of accelerators used diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index 6a281d88e9..123073917c 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -947,13 +947,16 @@ x_event_mask_to_gdk_event_mask (long mask) * @anid: a native window handle. * * Wraps a native window in a #GdkWindow. - * This may fail if the window has been destroyed. + * This may fail if the window has been destroyed. If the window + * was already known to GDK, a new reference to the existing + * #GdkWindow is returned. * * For example in the X backend, a native window handle is an Xlib * XID. * - * Return value: the newly-created #GdkWindow wrapper for the - * native window or %NULL if the window has been destroyed. + * Return value: a #GdkWindow wrapper for the native window or + * %NULL if the window has been destroyed. The wrapper will be + * newly created, if one doesn't exist already. * * Since: 2.2 **/ @@ -975,7 +978,10 @@ gdk_window_foreign_new_for_display (GdkDisplay *display, g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL); display_x11 = GDK_DISPLAY_X11 (display); - + + if ((window = gdk_xid_table_lookup_for_display (display, anid)) != NULL) + return g_object_ref (window); + gdk_error_trap_push (); result = XGetWindowAttributes (display_x11->xdisplay, anid, &attrs); if (gdk_error_trap_pop () || !result) -- 2.30.2